﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="robot.aspx.cs" Inherits="KSGJ.robot" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="ie=9;ie=8" />
    <title>权限设置</title>
    <script src="/ksgj/Scripts/jquery.min.js" type="text/javascript"></script>
    <script src="/ksgj/Scripts/jquery.loadthumb.js" type="text/javascript"></script>
    <script src="/ksgj/Scripts/jquery.simplemodal.js" type="text/javascript"></script>
    <script type="text/javascript" src="/ksgj/Scripts/jquery.meerkat.min.js"></script>
    <link href="/ksgj/css/MainSet.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/Header_Nav.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/sidebar.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/From_Effect.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/btn.css" rel="stylesheet" type="text/css" />
    <link href="/ksgj/css/basic.css" rel="stylesheet" type="text/css" />
<%--    <script src="/Scripts/jquery.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.loadthumb.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.simplemodal.js" type="text/javascript"></script>
    <script src="/Scripts/DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script src="Scripts/jquery.meerkat.min.js" type="text/javascript"></script>
    <link href="/css/MainSet.css" rel="stylesheet" type="text/css" />
    <link href="/css/Header_Nav.css" rel="stylesheet" type="text/css" />
    <link href="/css/sidebar.css" rel="stylesheet" type="text/css" />
    <link href="/css/From_Effect.css" rel="stylesheet" type="text/css" />
    <link href="/css/btn.css" rel="stylesheet" type="text/css" />
    <link href="/css/basic.css" rel="stylesheet" type="text/css" />--%>
    <!-- IE6 "fix" for the close png image -->
    <!--[if lt IE 7]>
        <link type='text/css' href='/ksgj/css/basic_ie.css' rel='stylesheet' media='screen' />
    <![endif]-->
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $("a.btn").wrapInner("<span></span>");
            $("a.btn, button, .pager img").hover(function () {
                $(this).stop().fadeTo(200, 0.7);
            }, function () {
                $(this).stop().fadeTo(200, 1.0);
            });
            $(".mark").mousedown(function () {
                $(this).addClass("checkbox-clicked");
            }).mouseup(function () {
                $(this).removeClass("checkbox-clicked");
            }).hover(function () {
                $(this).toggleClass("checkbox-hover");
            });
            $(".radiomark").mousedown(function () {
                $(this).addClass("radio-button-clicked");
            }).mouseup(function () {
                $(this).removeClass("radio-button-clicked");
            }).hover(function () {
                $(this).toggleClass("radio-button-hover");
            });
            $(".subcheck").change(function () {
                var subchk = $('.subcheck');
                var isallchk = (subchk.length == $(".subcheck:checked").length ? true : false);
                $("#allcheck").attr("checked", isallchk);
                if (isallchk) {
                    $("#allcheck").parent().next("label").addClass("checkbox-checked");
                }
                else {
                    $("#allcheck").parent().next("label").removeClass("checkbox-checked");
                }
                if (this.checked) {
                    $(this).parent("label").addClass("checkbox-checked");
                    //                    $(this).parent().parent().siblings("td").eq(0).css("color", "red");
                    //                    $(this).parent().parent().siblings("td").eq(1).children("select").removeAttr("disabled");
                    $(this).parent().parent().siblings("td").eq(2).children("input:text").removeAttr("disabled").focus();
                }
                else {
                    $(this).parent("label").removeClass("checkbox-checked");
                    //                    $(this).parent().parent().siblings("td").eq(0).css("color", "");
                    //                    $(this).parent().parent().siblings("td").eq(1).children("select").val("").attr("disabled", "disabled");
                    $(this).parent().parent().siblings("td").eq(2).children("input:text").val("").attr("disabled", "disabled");
                }
            });
            $("#allcheck").change(function () {
                var flag = this.checked;
                $('.subcheck').attr("checked", flag);
                if (flag) {
                    $(this).parent().next("label").addClass("checkbox-checked");
                    $('.subcheck').parent("label").addClass("checkbox-checked");
                    //$(".custom-checkbox").parent().siblings("td").css("color", "red");
                    $(".subcheck").parent().parent().siblings("td").children("input:text").removeAttr("disabled");
                }
                else {
                    $(this).parent().next("label").removeClass("checkbox-checked");
                    $('.subcheck').parent("label").removeClass("checkbox-checked")
                    //                    $(".custom-checkbox").parent().siblings("td").css("color", "");
                    //                    $(".custom-checkbox").parent().siblings("td").children("select").val("").attr("disabled", "disabled");
                    $(".subcheck").parent().parent().siblings("td").children("input:text").val("").attr("disabled", "disabled");
                }
            });
            $(".radiobutton").change(function () {
                var name = $(this).attr("name");
                var selectedvalue = $("input[name='" + name + "']:checked").val();
                if (selectedvalue == 0) {
                    $(this).parent("label").addClass("radio-button-checked");
                    $(this).parent("label").next().removeClass("radio-button-checked");
                }
                else {
                    $(this).parent("label").addClass("radio-button-checked");
                    $(this).parent("label").prev().removeClass("radio-button-checked");
                }
            })

            $("#savesubuser").click(function () {
                var $subuserlist = $("#subusertable").children("tbody").children("tr");
                var subidlist = "";
                var subusername = "";
                var submaxmoney = "";
                var suballpromotion = "";
                var re = /^(([0-9]+\.[0-9]{2})|([0-9]*[1-9][0-9]*))$/;
                var errormsg = false;
                $subuserlist.each(function () {

                    var issave = $(this).children("td").eq(0).children().children(":checkbox").attr("checked");
                    if (issave) {
                        var subid = $(this).children("td").eq(1).children("span").eq(1).text();
                        var maxmoney = $(this).children("td").eq(3).children(":text").eq(0).val();
                        var subname = $(this).children("td").eq(1).children("span").eq(0).text();
                        var allpromotion = $(this).children("td").eq(4).children().children(":radio:checked").val();
                        if (!re.test(maxmoney)) {
                            alert("请输入正确的金额,比如:28.35");
                            $(this).children("td").eq(3).children(":text").eq(0).focus();
                            errormsg = true;
                            return false;
                        }
                        subusername += subname + ",";
                        subidlist += subid + ",";
                        submaxmoney += maxmoney + ",";
                        suballpromotion += allpromotion + ","
                    }
                });
                if (errormsg) {
                    return false;
                }
                else {
                    $.ajax({
                        type: "POST",
                        //url: "/AjaxCommand/savesubuser.ashx",
                        url: "/ksgj/AjaxCommand/savesubuser.ashx",
                        data: {
                            idlist: subidlist.substr(0, subidlist.length - 1),
                            subname: subusername.substr(0, subusername.length - 1),
                            maxmoneylist: submaxmoney.substr(0, submaxmoney.length - 1),
                            allpromotion: suballpromotion.substr(0, suballpromotion.length - 1)
                        },
                        beforeSend: function (XMLHttpRequest) {
                            $("#alertbox").modal({
                                overlayCss: { backgroundColor: "#4d4d4d" },
                                close: false,
                                containerCss: {
                                    backgroundColor: "#fff",
                                    borderColor: "#ddd",
                                    height: 150,
                                    width: 400
                                }
                            });
                        },
                        success: function (data, textStatus, jqXHR) {
                            alert(data);
                        },
                        complete: function (XMLHttpRequest, textStatus) {
                            $.modal.close();
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            // 通常 textStatus 和 errorThrown 之中
                            // 只有一个会包含信息
                            //alert(XMLHttpRequest); // 调用本次AJAX请求时传递的options参数
                            alert("保存子账户信息失败，请稍后再试！");
                        }
                    });
                }
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div id="height-wrapper">
        <div>
            <div id="header_toolbar">
                <div class="container_12">
                    <h1>
                        <span>快速改价</span>
                        <span style="font-size:14px;float:right;">
                            请使用以下浏览器获得最佳浏览效果:
                            <a target="_blank" title="谷歌浏览器" href="http://www.google.cn/chrome/intl/zh-CN/landing_chrome.html?hl=zh_cn&brand=CHMA&utm_campaign=zh_cn&utm_source=zh_cn-ha-apac-zh_cn-bk&utm_medium=ha">
                                <img src="img/browsers/Chrome.png" alt="chrome" class="browsersimg" />
                            </a>
                            <a target="_blank" title="遨游3浏览器" href="http://www.maxthon.cn/mx3/">
                                <img src="img/browsers/Maxthon.png" alt="maxthon" class="browsersimg" />
                            </a>
                            <a target="_blank" title="火狐浏览器" href="http://firefox.com.cn/download/">
                                <img src="img/browsers/Firefox.png" alt="firefox" class="browsersimg" />
                            </a>
                            <a target="_blank" title="IE8浏览器" href="http://windows.microsoft.com/zh-CN/internet-explorer/downloads/ie-8">
                                <img src="img/browsers/IE.png" alt="ie" class="browsersimg" />
                            </a>
                            <a target="_blank" title="腾讯TT浏览器" href="http://tt.qq.com/">
                                <img src="img/browsers/Traveler.png" alt="traveler" class="browsersimg" />
                            </a>
                            <a target="_blank" title="360极速浏览器" href="http://chrome.360.cn/">
                                <img src="img/browsers/360jisu.png" alt="traveler" class="browsersimg" />
                            </a>
                        </span>
                    </h1>
                </div>
            </div>
            <nav id="header_main">
                <div class="container_12">
                    <ul id="nav_main">
                        <li>
                            <a href="Index.aspx">
                                <img src="img/icons/25x25/blue/computer-imac.png" width="25" height="25" alt="" />
                                单人改价
                            </a>
                        </li>
                        <li>
                            <a href="allindex.aspx">
                                <img src="img/icons/25x25/blue/blocks---images.png" width="25" height="25" alt="" />
                                全网折扣
                            </a>
                        </li>
                        <li class="current">
                            <a href="robot.aspx">
                                <img src="img/icons/25x25/blue/user.png" width="25" height="25" alt="" />
                                权限设置
                            </a>
                            <ul>
                                <li>
                                    <span>为每个子账户设置使用权限</span>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </nav>
            <div id="nav_sub"></div>
        </div>
        <div class="container_12" style="min-height:560px;">
            <asp:UpdatePanel ID="contentwrapper" runat="server">
                <ContentTemplate>
                    <div class="box">
                        <div class="header">
                            <img src="img/icons/16x16/user.png" width="16" height="16" alt="" />
                            <h3>子账户列表</h3>
                        </div>
                        <asp:Panel CssClass="content" style="padding:0;" ID="notuse" Visible="false" runat="server">
                        </asp:Panel>
                        <asp:Panel ID="notusePanel" runat="server" CssClass="alert error" Visible="false" >
                                <span class="icon"></span>
                                <strong>错误</strong>
                                只有主账户才能设置权限
                        </asp:Panel>
                        <asp:Panel ID="subpanel" CssClass="content" style="padding:0;" runat="server">
                            <table class="table" id="subusertable">
                                <thead>
                                    <tr>
                                        <th style="width:56px;text-align:center;">
                                            <asp:CheckBox ID="allcheck" runat="server" CssClass="hidden" />
                                            <label class="checkbox" for="allcheck">
                                                <span class="mark">
                                                    <img src="img/sprites/forms/checkboxes/empty.png" alt="" />
                                                </span>
                                            </label>
                                        </th>
                                        <th style="width:131px">
                                            子账户用户名
                                        </th>
                                        <th style="width:131px">
                                            子账户姓名
                                        </th>
                                        <th style="width:131px">
                                            最大优惠金额
                                        </th>
                                        <th style="width:131px">
                                            是否允许使用全网折扣
                                        </th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <asp:Repeater ID="userlist" runat="server" 
                                        onitemdatabound="userlist_ItemDataBound">
                                        <ItemTemplate>
                                            <tr>
                                                <td style="text-align:center;">
                                                    <label class="checkbox" id="sublabel" runat="server">
                                                        <input type="checkbox" id="subcheckbox" class="subcheck hidden" runat="server" />
                                                        <span class="mark">
                                                            <img src="img/sprites/forms/checkboxes/empty.png" alt="" />
                                                        </span>
                                                    </label>
                                                </td>
                                                <td><span><%# Eval("nick")%></span><span class="hidden"><%# Eval("subid") %></span></td>
                                                <td><%# Eval("fullname")%></td>
                                                <td>
                                                    <asp:TextBox ID="maxmoney" runat="server" Enabled="false" style="margin:0;"></asp:TextBox>
                                                </td>
                                                <td style="text-align:center">
                                                    <label class="radio-button" id="radiolabel1" runat="server" style="display:inline">是
                                                        <input type="radio" name="subradio"  id="radio1" class="radiobutton hidden" value="0" runat="server" />
                                                        <span class="radiomark">
                                                            <img src="img/sprites/forms/checkboxes/empty.png" alt="" />
                                                        </span>
                                                    </label>
                                                    <label class="radio-button radio-button-checked" id="radiolabel2" runat="server" style="display:inline">否
                                                        <input type="radio" name="subradio"  id="radio2" class="radiobutton hidden" value="1" runat="server" />
                                                        <span class="radiomark">
                                                            <img src="img/sprites/forms/checkboxes/empty.png" alt="" />
                                                        </span>
                                                    </label>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                    </asp:Repeater>
                                </tbody>
                            </table>
                        </asp:Panel>
                        <asp:Panel ID="controlpanel" style="margin:10px 0;text-align:right;" runat="server">
                            <a class="btn blue" id="savesubuser">&nbsp;&nbsp;确&nbsp;定&nbsp;&nbsp;</a>
                        </asp:Panel>
                    </div>
                </ContentTemplate>
                <Triggers>
                </Triggers>
            </asp:UpdatePanel>
        </div>
    </div>
    <div id="footer">
        <div class="container_12">
            <span>© 2010-2011武汉卓天信息科技有限公司版权所有</span>&nbsp;&nbsp;&nbsp;
            <span>
                客服旺旺:&nbsp;<a target="_blank" href="http://amos.im.alisoft.com/msg.aw?v=2&uid=%E6%AD%A6%E6%B1%89%E5%8D%93%E5%A4%A9%E7%A7%91%E6%8A%80%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&site=cntaobao&s=1&charset=utf-8" ><img border="0" style="vertical-align:middle;" src="http://amos.im.alisoft.com/online.aw?v=2&uid=%E6%AD%A6%E6%B1%89%E5%8D%93%E5%A4%A9%E7%A7%91%E6%8A%80%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8&site=cntaobao&s=1&charset=utf-8" alt="有问必答" /></a>
            </span>
            <span>
                客服邮箱:&nbsp;<span>ex_sky@163.com</span>
            </span>
            <span>
                客服电话:&nbsp;<span>027-82420526</span>&nbsp;<span>18971460801</span>
            </span>
            <span>
                <a href="http://bangpai.taobao.com/group/14509393.htm" target="_blank">进入帮派</a>
            </span>
        </div>
    </div>
    <div id="alertbox" style="display:none">
        <h3>正在保存设置,请稍后...</h3>
        <p style="color:Black">请不要刷新或关闭页面!</p>
        <img id="Img1" src="img/loading.gif" alt="" />
    </div>
    </form>
    <script type="text/javascript" src="http://toptrace.taobao.com/assets/getAppKey.js" topappkey="12310450" defer="defer"></script>
</body>
</html>
